package jp.ac.aiit.yc.softarch.hbcp.service.kj;

import java.util.LinkedList;
import java.util.List;

import jp.ac.aiit.yc.softarch.hbcp.model.kj.Card;

public class KjService {

	private static List<Card> cards = new LinkedList<Card>();

	public void saveCard(Card card) {
		for (int i = 0;i < cards.size();i++) {
			if (cards.get(i).getUid().equals(card.getUid())) {
				cards.set(i, card);
				return ;
			}
		}
		cards.add(card);
	}

	public void toFront(Card card) {
		for (int i = 0;i < cards.size();i++) {
			if (cards.get(i).getUid().equals(card.getUid())) {
				Card c = cards.remove(i);
				cards.add(c);
				return ;
			}
		}
	}
	public List<Card> getCards() {
		System.out.println(cards);
		return cards;
	}

	public void deleteCard(Card card) {
		for (int i = 0;i < cards.size();i++) {
			if (cards.get(i).getUid().equals(card.getUid())) {
				cards.remove(i);
				return ;
			}
		}
	}
}
